import os
from flask import Flask, render_template, request
from werkzeug.utils import secure_filename

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = 'C:/Users/A/Desktop/'  # 定义上传文件夹的路径


@app.route('/upload')
def upload_file():
    return render_template('index.html')


@app.route('/uploader', methods=['GET', 'POST'])
def uploader():
    if request.method == 'POST':
        f = request.files['file']
        print(request.files)
        # document = Document()
        f.save(os.path.join(app.config['UPLOAD_FOLDER'], secure_filename(f.filename)))
        return 'file uploaded successfully'  # 成功上传后页面
    else:
        return render_template('index.html')  # 默认显示页面


if __name__ == '__main__':
    app.run(debug=True)
